// 时间转化年月日
export const transformTimeTwo = (date, dateed) => {
  var d = '',
    m = '',
    day = '',
    datetime = '',
    h = '',
    min = '',
    s = ''
  d = new Date(date)
  m = d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : d.getMonth() + 1
  day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
  h = d.getHours() < 10 ? '0' + d.getHours() : d.getHours()
  min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
  s = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds()
  if (dateed == 'date') {
    datetime = d.getFullYear() + '-' + m + '-' + day
    return datetime
  }
  if (dateed == 'minutes') {
    datetime = d.getFullYear() + '-' + m + '-' + day + ' ' + h + ':' + min
    return datetime
  } else {
    datetime = d.getFullYear() + '-' + m + '-' + day + ' ' + h + ':' + min + ':' + s
    return datetime
  }
}
export const transformTime = (date, num) => {
  var d = '',
    m = '',
    day = '',
    datetime = '',
    h = '',
    min = '',
    s = ''
  if (num == 1 || num == 2 || num == 3 || num == 4) {
    d = new Date(date)
  } else {
    d = new Date(date * 1000)
  }
  //   d = new Date(date * 1000);
  m = d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : d.getMonth() + 1
  day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
  h = d.getHours() < 10 ? '0' + d.getHours() : d.getHours()
  min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
  s = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds()
  if (num == 1) {
    datetime = h + ':' + min
  } else if (num == 2) {
    datetime = m + '-' + day
  } else if (num == 3) {
    datetime = m + '-' + day + ' ' + h + ':' + min
  } else if (num == 4) {
    datetime = d.getFullYear() + '-' + m + '-' + day + ' ' + '07:00:00'
  } else {
    datetime = d.getFullYear() + '-' + m + '-' + day + ' ' + h + ':' + min + ':' + s
  }

  return datetime
}
// 如果是当年  时间转化年月日
export const transformTimeCheck = (date, dateed) => {
  var d = '',
    m = '',
    day = '',
    datetime = '',
    h = '',
    min = '',
    s = '',
    dCheck = '',
    dayCheck = ''
  d = new Date(date)
  dCheck = new Date(new Date())

  m = d.getMonth() + 1 < 10 ? '0' + (d.getMonth() + 1) : d.getMonth() + 1
  day = d.getDate() < 10 ? '0' + d.getDate() : d.getDate()
  dayCheck = dCheck.getDate() < 10 ? '0' + dCheck.getDate() : dCheck.getDate()
  h = d.getHours() < 10 ? '0' + d.getHours() : d.getHours()
  min = d.getMinutes() < 10 ? '0' + d.getMinutes() : d.getMinutes()
  s = d.getSeconds() < 10 ? '0' + d.getSeconds() : d.getSeconds()
  if (dateed == 'date') {
    if (d.getFullYear() == dCheck.getFullYear()) {
      datetime = m + '-' + day
    } else {
      datetime = d.getFullYear() + '-' + m + '-' + day
    }
    return datetime
  }
  if (dateed == 'minutes') {
    if (d.getFullYear() == dCheck.getFullYear()) {
      console.log(day)
      if (day == dayCheck) {
        datetime = h + ':' + min
      } else {
        datetime = m + '-' + day + ' ' + h + ':' + min
      }
    } else {
      datetime = d.getFullYear() + '-' + m + '-' + day + ' ' + h + ':' + min
    }
    return datetime
  } else {
    datetime = d.getFullYear() + '-' + m + '-' + day + ' ' + h + ':' + min + ':' + s
    return datetime
  }
}
